package com.baoyi.landscape;

import java.util.List;

import net.youmi.android.AdManager;
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.baoyi.adapter.Items;
import com.baoyi.content.content;
import com.baoyi.doamin.WorkItem;

/**
 * 大师作品列表
 * 
 * @author Administrator
 * 
 */
public class WorkListUI extends Activity {
	private List<WorkItem> itemsss;
	private Items items;
	static{
		AdManager.init(content.id, content.pwd, content.time, content.con,content.banben);
	}
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.worklist);
		ListView la = (ListView) findViewById(R.id.listView1);
		la.setDividerHeight(0);
		
		
	
		
		
		items = new Items(this);
		la.setAdapter(items);
		la.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				Intent item = new Intent(WorkListUI.this, WorkViewUI.class);
				WorkItem it = (WorkItem) items.getItem(arg2);
				item.putExtra("it", it);
				Log.d(BaoyiApplication.TAG, "arg2:" + arg2 + "arg3:" + arg3);
				startActivity(item);
			}
		});
	}
	@Override
	protected Dialog onCreateDialog(int id) {
		switch (id) {
		case 1: {
			ProgressDialog dialog = new ProgressDialog(this);
			dialog.setTitle("Indeterminate");
			dialog.setMessage("Please wait while loading...");
			dialog.setIndeterminate(true);
			dialog.setCancelable(true);
			return dialog;
		}
		case 2: {
			ProgressDialog dialog = new ProgressDialog(this);
			dialog.setMessage("正在为你加载内容，请等待...");
			dialog.setIndeterminate(true);
			dialog.setCancelable(true);
			return dialog;
		}
		}
		return null;
	}
}
